#pragma once

#ifdef GK_DEVICE_DIRECTX9

#include "..\GkContextInterface.h"
#include "GkRenderSurface.h"
#include "GkBuffer.h"
#include "GkGpuProgram.h"
#include "GkStreamDescription.h"
#include "GkGpuProgram.h"
#include "GkTexture.h"
#include "GkTypeConversion.DirectX9.h"

namespace gk
{
	struct ContextInternal : public ContextInterface
	{
		LPDIRECT3DDEVICE9		m_pD3DDevice;
		RenderTarget			m_currentRenderTarget;
		IDirect3DVertexShader9*	m_pCurVertexShader;
		IDirect3DPixelShader9*	m_pCurPixelShader;
		StateBlock				m_currentState;
		bool					m_flushState;
		RenderBindingHandle		m_hCurRenderBinding;
		bool					m_samplersUsed[Constants::MaxSamplers];

		ContextInternal();

		void BeginFrame();
		void EndFrame();
		void SetRenderTarget(RenderTargetHandle hRenderTarget);
		void ClearRenderTarget(ClearType::Enum clearType, float r, float g, float b, float a, float depth, cr::uint8_t stencil);
		void SetRenderBinding(RenderBindingHandle hRenderBinding);
		void DrawIndexedPrimitives(BufferHandle hIndexBuffer, PrimitiveType::Enum primitiveType, cr::size_t indexCount, cr::size_t startIndex, cr::size_t vertexCount, cr::size_t startVertex);
		void DrawPrimitives(PrimitiveType::Enum primitiveType, cr::size_t startVertex, cr::size_t numVertices);
		void BeginGpuProgram(GpuProgramHandle hGpuProgram);
		void EndGpuProgram();
		void CommitConstantBuffer(ConstantBufferHandle hConstantBuffer);
		void CommitGpuProgram();
		void CommitStateBlock(StateBlockHandle hStateBlock);
	};
}

#endif // GK_DEVICE_DIRECTX9